SrcInfo := Info; DestPic := Trunc(FinalImage); Info := pointer(WindowPeek(PicWindow[DestPic])^.RefCon); DstInfo := Info;{assign it to DstInfo} for vloc := RoiTop to RoiBottom - 1 do begin Info := SrcInfo; GetLine(RoiLeft, vloc, width, CurLinePtr^); {Do something with the data and put the data to the other window} NewLinePtr^[hloc] := CurLinePtr^[hloc]*myfactor Info := DstInfo; PutLine(RoiLeft, vloc, width, NewLinePtr^);
{Set up multiple for loops for nPics and each SliceCount} for PictureNumber := 1 to npics... {You must find the previous data offset for the final array} CurrentInfo := Info; PreviousEndOfData := 0; for i := 1 to PictureNumber - 1 do begin TempInfo := pointer(WindowPeek(PicWindow[i])^.RefCon); Info := TempInfo; with Info^.PicRect do begin Previouswidth := right - left; Previousheight := bottom - top; end; if Info^.StackInfo <> nil then PreviousSliceCount := Info^.StackInfo^.nSlices else PreviousSliceCount := 1; BytesUsed := PreviousSliceCount * PreviousWidth * PreviousHeight; PreviousEndOfData := PreviousEndOfData + BytesUsed; end; Info := CurrentInfo; {Find how many slices in the current pic} if Info^.StackInfo <> nil then SliceCount := Info^.StackInfo^.nSlices else SliceCount := 1; For SliceNumber := 1 to SliceCount .... {Set up rest of the for loops here. The usual, up to hloc & vloc} {put those here} {Now compute a unique array offset} ArrayOffset := PreviousEndOfData + (SliceNumber - 1) * LongInt(width) * height + LongInt(width) * longInt(vloc) + LongInt(hloc); {Finally store your calculation into a unique location} MyHugeArray^[ArrayOffset] := SomeCalculatedValue;
function GetDNum (TheDialog: DialogPtr; item: integer): LongInt; function GetDString (TheDialog: DialogPtr; item: integer): str255; function GetDReal (TheDialog: DialogPtr; item: integer): extended;
procedure SetDNum (TheDialog: DialogPtr; item: integer; n: LongInt); procedure SetDReal (TheDialog: DialogPtr; item: integer; n: extended; fwidth: integer); procedure SetDString (TheDialog: DialogPtr; item: integer; str: str255); procedure SetDialogItem (TheDialog: DialogPtr; item, value: integer);
mylog := GetNewDialog(130, nil, pointer(-1)); {retrieve the dialog box} Do default SET's here OutlineButton(MyLog, ok, 16); repeat ModalDialog(nil, item); if item = SomeDialogItemID then begin Get or Set something ... lots of if statements to check which item is pressed until (item = ok) or (item = cancel); DisposDialog(mylog);
function OptionKeyDown: boolean; function ShiftKeyDown: boolean; function ControlKeyDown: boolean; function SpaceBarDown: boolean;
if OptionKeyDown then begin DoSomething; end else begin DoSomeThingElse; end;
function CommandPeriod: boolean;
if CommandPeriod then begin beep; exit(YourLoopingProcedure) end;
Function Button:boolean;The button functions are explained in Inside Mac
const MaxTextBufSize = 32700; type TextBufType = packed array[1..MaxTextBufSize] of char; TextBufPtr = ^TextBufType; var TextBufP: TextBufPtr; TextBufSize, TextBufColumn, TextBufLineCount: integer;
cr := chr(13); tab := chr(9); BackSpace := chr(8); eof := chr(4);
TextBufP := TextBufPtr(NewPtr(Sizeof(TextBufType)));
Expansion of PutString may help in the understanding of the functionality involved:
procedure PutChar (c: char); procedure PutTab; procedure PutString (str: str255); procedure PutReal (n: extended; width, fwidth: integer); procedure PutLong (n: LongInt; FieldWidth: integer);
procedure PutString (str: str255); var i: integer; begin for i := 1 to length(str) do begin if TextBufSize < MaxTextBufSize then TextBufSize := TextBufSize + 1; TextBufP^[TextBufSize] := str[i]; TextBufColumn := TextBufColumn + 1; end; end>An example call sequence which places text into textbuffer might look something like:
PutSting('Number of Pixels'); PutTab; PutString('Area'); putChar(cr);To Save the textbuffer, the procedure SaveAsText can be used after a SFPPutfile to FSWrite data to the disk or other output.
procedure SampleSaveBuffer; var Where: point; reply: SFReply; begin SFPutFile(Where, 'Save as?', 'Buffer data', nil, reply); if not reply.good then exit(SampleSaveBuffer); with reply do SaveAsText(fname, vRefNum); {this will handle the FSWriting} end;